package com.xwaf.platform.web.controller.pay;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.xwaf.platform.common.api.CommonResponse;
import com.xwaf.platform.common.utils.DateHelper;
import com.xwaf.platform.common.web.BaseController;
import com.xwaf.platform.system.api.entity.pay.Apply;
import com.xwaf.platform.system.api.request.three.WeiXinProductRequest;
import com.xwaf.platform.system.api.service.pay.WeiXinService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@Api(tags = "微信")
@RequestMapping(value = "/x/wx/")
public class WeiXinController extends BaseController {
	@Autowired
	private WeiXinService weiXinService;
	// @Autowired
	// GenSnHandler genSnHandler;

	// http://localhost:8080/x/wx/getWeixinAppPaySign?appId=XXX&mchId=XXX&apiKey=XXX
	@ApiOperation(value = "微信APP签名", httpMethod = "GET")
	@GetMapping("/getWeixinAppPaySign")
	@ResponseBody
	public CommonResponse getWeixinAppPaySign(WeiXinProductRequest order) {
		// order.setOrderNo(genSnHandler.createOrderSn());//redis 链接问题
		order.setOrderNo(DateHelper.getTimeStampInSeconds());// 毫秒级时间戳
		Map<String, String> appPayRequest = weiXinService.appPayRequest(order);
		return CommonResponse.createCommonResponse(appPayRequest);
	}
}
